<div class="content-section introduction">
    <div>
        <span class="feature-title">Terminal</span>
        <span>Terminal is a text based user interface. Enter "date" to display the current date.</span>
    </div>
</div>

<div class="content-section implementation">
    <p-terminal welcomeMessage="Welcome to PrimeNG" prompt="primeng $"></p-terminal>
</div>

<div class="content-section documentation">
    <p-tabView effect="fade">
        <p-tabPanel header="Documentation">
            <h3>Import</h3>
<pre>
<code class="language-typescript" pCode ngNonBindable>
import &#123;TerminalModule&#125; from 'primeng/terminal';
</code>
</pre>

            <h3>Getting Started</h3>
            <p>Commands are processed using observables via the TerminalService. Import this service into your component and subscribe
            to commandHandler to process commands by sending replies with sendResponse function.</p>
<pre>
<code class="language-typescript" pCode ngNonBindable>
import &#123;Component&#125; from '@angular/core';
import &#123;TerminalService&#125; from 'primeng/components/terminal/terminalservice';

@Component(&#123;
    template: '&lt;p-terminal welcomeMessage="Welcome to PrimeNG" prompt="primeng $"&gt;&lt;/p-terminal&gt;',
    providers: [TerminalService]
&#125;)
export class TerminalDemo &#123;
    
    constructor(private terminalService: TerminalService) &#123;
        this.terminalService.commandHandler.subscribe(command => &#123;
            let response = (command === 'date') ? new Date().toDateString() : 'Unknown command: ' + command;
            this.terminalService.sendResponse(response);
        &#125;);
    &#125;
&#125;
</code>
</pre>

            <h3>Properties</h3>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Type</th>
                            <th>Default</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>welcomeMessage</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Initial text to display on terminal.</td>
                        </tr>
                        <tr>
                            <td>prompt</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Prompt text for each command.</td>
                        </tr>
                        <tr>
                            <td>style</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Inline style of the component.</td>
                        </tr>
                        <tr>
                            <td>styleClass</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Style class of the component.</td>
                        </tr>
                    </tbody>
                </table>
            </div>
            
            <h3>Styling</h3>
            <p>Following is the list of structural style classes, for theming classes visit <a href="#" [routerLink]="['/theming']">theming page</a>.</p>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Element</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>ui-terminal</td>
                            <td>Container element.</td>
                        </tr>
                        <tr>
                            <td>ui-terminal-content</td>
                            <td>Content of terminal.</td>
                        </tr>
                        <tr>
                            <td>ui-terminal-content-prompt</td>
                            <td>Prompt text.</td>
                        </tr>
                        <tr>
                            <td>ui-terminal-input</td>
                            <td>Input element to enter commands.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h3>Dependencies</h3>
            <p>None.</p>
        </p-tabPanel>

<p-tabPanel header="Source">
    <a href="https://github.com/primefaces/primeng/tree/master/src/app/showcase/components/terminal" class="btn-viewsource" target="_blank">
        <i class="fa fa-github"></i>
        <span>View on GitHub</span>
    </a>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-terminal welcomeMessage="Welcome to PrimeNG" prompt="primeng $"&gt;&lt;/p-terminal&gt;
</code>
</pre>
    
<pre>
<code class="language-typescript" pCode ngNonBindable>
import &#123;Component&#125; from '@angular/core';
import &#123;TerminalService&#125; from 'primeng/components/terminal/terminalservice';
import &#123;Subscription&#125; from 'rxjs/Subscription';

@Component(&#123;
    templateUrl: './terminaldemo.html',
    providers: [TerminalService]
&#125;)
export class TerminalDemo &#123;

    subscription: Subscription;
    
    constructor(private terminalService: TerminalService) &#123;
        this.terminalService.commandHandler.subscribe(command => &#123;
            let response = (command === 'date') ? new Date().toDateString() : 'Unknown command: ' + command;
            this.terminalService.sendResponse(response);
        &#125;);
    &#125;
    
    ngOnDestroy() &#123;
        if(this.subscription) &#123;
            this.subscription.unsubscribe();
        &#125;
    &#125;
&#125;
</code>
</pre>
</p-tabPanel>


    </p-tabView>
</div>